﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bloodbank.Dto;

namespace Bloodbank.Api
{
    public class BloodGroupApi
    {
        private BloodbankDbEntities contextDB;
        public BloodGroupApi() {
            contextDB = new BloodbankDbEntities();
        }

        public List<BloodGroupDto> GetGroupBloodList()
        {
            try
            {
                var objGroupBloods = contextDB.BloodGroups.ToList();
                List<BloodGroupDto> lstGroupBood = new List<BloodGroupDto>();
                foreach (var obj in objGroupBloods)
                {
                    BloodGroupDto bloodGroup = new BloodGroupDto()
                    {
                        Id = obj.Id,
                        BloodGroupName = obj.BloodGroupName
                    };
                    lstGroupBood.Add(bloodGroup);
                }
                return lstGroupBood;
            }
            catch (Exception ex) { return new List<BloodGroupDto>(); }
        }
    }
}
